<?php

declare (strict_types = 1);

namespace app\common\repository;

use app\common\repository\BaseRepository;
use app\common\model\CodexPrice;

class CodexPriceRepository extends BaseRepository
{
    protected \app\common\model\BaseModel $model;

    public function __construct(CodexPrice $model)
    {
        $this->model = $model;
    }

    /**
     * 获取最新价格
     *
     * @return mixed
     */
    public function getNewPrice(): mixed
    {
        return $this->model->order('create_time', 'desc')->limit(1)->value('price');
    }
}